/**
 * 提示框
 * @param {*} content 
 * @param {*} onok 
 * @param {*} needcancel 
 */
window.createMsgBox = function(content,successCallBack=null,cancelCallBack=null)
{
    cc.resources.load("prefabs/common/alert",cc.Prefab, function(err, loadedResource) {
        if (err) {cc.log('载入预制资源失败， 原因:' + err); return}
        let tipPrefab = cc.instantiate(loadedResource)
        let tipScript = tipPrefab.getComponent("Alert")
        tipScript.init(content,successCallBack,cancelCallBack);
        cc.director.getScene().addChild(tipPrefab, ZORDER.ALERT,'Alert')
    });
}

/**
 * 信息提示语
 * @param {*} content   
 * @param {*} onok 
 * @param {*} needcancel 
 */
 window.createTips = function(msg='', type=Global.Code.DEFAULT)
 {
     cc.resources.load("prefabs/common/tips",cc.Prefab, function(err, loadedResource) {
         if (err) {cc.log('载入预制资源失败， 原因:' + err); return}
         let tipPrefab = cc.instantiate(loadedResource)
         let tipScript = tipPrefab.getComponent("Tips")
         tipScript.init(msg, type);
         cc.director.getScene().addChild(tipPrefab, ZORDER.TOAST,'Tips')
     });
 }
 
/**
 * 信息提示语
 * @param {*} content   
 * @param {*} onok 
 * @param {*} needcancel 
 */
 window.showWaiting = function(bshow=false)
 {
    let node = cc.director.getScene().getChildByName('Waiting');
    if (!bshow){
        if (node !== null) {
            node.stopAllActions()
            node.destroy()
        }
        return;
    }
    if (node !== null)return;

    cc.resources.load("prefabs/common/waiting",cc.Prefab, function(err, loadedResource) {
        if (err) {cc.log('载入预制资源失败， 原因:' + err); return}

        let node = cc.director.getScene().getChildByName('Waiting');
        if (node !== null) {
            return;
        }

        let tipPrefab = cc.instantiate(loadedResource)
        cc.director.getScene().addChild(tipPrefab, ZORDER.WAITING,'Waiting')
    });
 
}
